load("//:build_variables.bzl", "COPTS")
load("//tools/lint:linters.bzl", "clang_tidy_test")

package(
    default_visibility = ["//:android_cuttlefish"],
)

cc_library(
    name = "common",
    srcs = ["common.cpp"],
    hdrs = ["common.h"],
    copts = COPTS + [ "-Werror=sign-compare" ],
    deps = [
        "//cuttlefish/common/libs/utils:contains",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/host/commands/cvd/cli:types",
        "//cuttlefish/host/libs/config:config_utils",
        "//libbase",
    ],
)

clang_tidy_test(
    name = "common_clang_tidy",
    srcs = [":common"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "flags_collector",
    srcs = ["flags_collector.cpp"],
    hdrs = ["flags_collector.h"],
    copts = COPTS + [ "-Werror=sign-compare" ],
    deps = [
        "//libbase",
        "@tinyxml2",
    ],
)

clang_tidy_test(
    name = "flags_collector_clang_tidy",
    srcs = [":flags_collector"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "interrupt_listener",
    srcs = ["interrupt_listener.cpp"],
    hdrs = ["interrupt_listener.h"],
    copts = COPTS + [ "-Werror=sign-compare" ],
    deps = [
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:signals",
        "//libbase",
    ],
)

clang_tidy_test(
    name = "interrupt_listener_clang_tidy",
    srcs = [":interrupt_listener"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "subprocess_waiter",
    srcs = ["subprocess_waiter.cpp"],
    hdrs = ["subprocess_waiter.h"],
    copts = COPTS + [ "-Werror=sign-compare" ],
    deps = [
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:subprocess",
    ],
)

clang_tidy_test(
    name = "subprocess_waiter_clang_tidy",
    srcs = [":subprocess_waiter"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "utils",
    hdrs = [
        "common.h",
        "flags_collector.h",
        "interrupt_listener.h",
        "subprocess_waiter.h",
    ],
    copts = COPTS + [ "-Werror=sign-compare" ],
    deps = [
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:subprocess",
        "//cuttlefish/host/commands/cvd/cli:types",
        "//cuttlefish/host/commands/cvd/utils:common",
        "//cuttlefish/host/commands/cvd/utils:flags_collector",
        "//cuttlefish/host/commands/cvd/utils:interrupt_listener",
        "//cuttlefish/host/commands/cvd/utils:subprocess_waiter",
        "//libbase",
    ],
)

clang_tidy_test(
    name = "utils_clang_tidy",
    srcs = [":utils"],
    tags = ["clang_tidy", "clang-tidy"],
)
